package com.wx.router;

import me.chanjar.weixin.mp.api.WxMpMessageRouter;
import me.chanjar.weixin.mp.api.WxMpMessageRouterRule;

public abstract class BaseAllRouterCreater implements WxMpRouterRuleDetails, RouterCreater {

	private WxMpMessageRouter router;

	public BaseAllRouterCreater(WxMpMessageRouter router) {
		this.router = router;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.wx.router.RouterCreater#creater()
	 */
	@Override
	public WxMpMessageRouter creater() {
		this.ruleSubscribe();
		this.ruleUnsubscribe();
		this.ruleMenuKey();
		this.ruleMenuKey();
		return router;
	}

	@Override
	public void ruleSubscribe() {
		WxMpMessageRouterRule rule = this.router.rule().msgType("event").event("subscribe");
		dealSubscribe(rule);
		this.router = rule.end();
	}

	@Override
	public void ruleUnsubscribe() {
		WxMpMessageRouterRule rule = this.router.rule().msgType("event").event("unsubscribe");
		dealUnsubscribe(rule);
		this.router = rule.end();
	}

	@Override
	public void ruleScanQrCodeUnsubscribe() {
		WxMpMessageRouterRule rule = this.router.rule();
		dealScanQrCodeUnsubscribe(rule);
		this.router = rule.end();
	}

	@Override
	public void ruleScanQrCodeSubscribe() {
		WxMpMessageRouterRule rule = this.router.rule();
		dealScanQrCodeSubscribe(rule);
		this.router = rule.end();
	}

	@Override
	public void ruleLocationEnable() {
		WxMpMessageRouterRule rule = this.router.rule();
		dealLocationEnable(rule);
		this.router = rule.end();
	}

	@Override
	public void ruleMenuKey() {
		WxMpMessageRouterRule rule = this.router.rule().msgType("event").event("CLICK");
		dealMenuKey(rule);
		this.router = rule.end();

	}

	@Override
	public void ruleMenuUrl() {
		WxMpMessageRouterRule rule = this.router.rule().msgType("event").event("VIEW");
		dealMenuUrl(rule);
		this.router = rule.end();
	}

	@Override
	public void ruleTxtMsg() {
		WxMpMessageRouterRule rule = this.router.rule();
		dealTxtMsg(rule);
		this.router = rule.end();
	}

	@Override
	public void ruleImageMsg() {
		WxMpMessageRouterRule rule = this.router.rule();
		dealImageMsg(rule);
		this.router = rule.end();
	}

	@Override
	public void ruleVoiceMsg() {
		WxMpMessageRouterRule rule = this.router.rule();
		dealVoiceMsg(rule);
		this.router = rule.end();
	}

	@Override
	public void ruleVideoMsg() {
		WxMpMessageRouterRule rule = this.router.rule();
		dealVoiceMsg(rule);
		this.router = rule.end();
	}

	@Override
	public void ruleShortVideoMsg() {
		WxMpMessageRouterRule rule = this.router.rule();
		dealShortVideoMsg(rule);
		this.router = rule.end();
	}

	@Override
	public void ruleLocationMsg() {
		WxMpMessageRouterRule rule = this.router.rule();
		dealLocationMsg(rule);
		this.router = rule.end();
	}

	@Override
	public void ruleLinkMsg() {
		WxMpMessageRouterRule rule = this.router.rule();
		dealLinkMsg(rule);
		this.router = rule.end();
	}

}
